package com.kaifamiao.month04.day13;

public class Demo04 {

    public static void main(String[] args) {
        checkAge(10);
    }

    public static void checkAge(int age) {
        if(age < 0 || age > 120) {
            throw new AgeOutBoundsException("age 不在正常范围");
        }

        try {
            String str = null;
            str.lastIndexOf(1);
        } catch(NullPointerException e) {
            throw new AgeOutBoundsException("", e);
        }
        System.out.println("正常");
    }
}

class AgeOutBoundsException extends RuntimeException{

    public AgeOutBoundsException() {}

    public AgeOutBoundsException(String msg) {
        super(msg);
    }

    public AgeOutBoundsException(Throwable a) {
        super(a);
    }

    public AgeOutBoundsException(String msg, Throwable a) {
        super(msg, a); // a 造成该异常的其他异常对象，可以将其保存下来
    }
}
